﻿<!DOCTYPE html>
<html>
<head>
    <title>订单列表</title>
    <link rel="Stylesheet" type="text/css" href="${os.mcss}" />
    <link href="${os.ppath}/css.css" rel="stylesheet" type="text/css" />
    <link href="${os.ppath}/js/EasyUi/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="${os.ppath}/js/EasyUi/themes/icon.css" rel="stylesheet" type="text/css" />
    <style>
        .searchBar ul {
            list-style: none;
            padding: 0;
            margin: 10px 20px;
        }

            .searchBar ul li {
                float: left;
                padding-right: 10px;
                margin: 2px 0;
                white-space: nowrap;
            }

        .sf-2 {
            color: #333;
        }

        .sf-1, .sf-3 {
            color: red;
        }

        .sf0 {
            color: #ff6600;
        }

        .sf1, .sf2 {
            color: green;
        }
    </style>
</head>
<body>


    <div id="gd">
    </div>


    <div class="toolBar">
        <div class="searchBar padding5" id="searchbar">
            <ul style="width:60%">
                <!--<li><b>搜索条件：</b></li>-->
                <li>
                    <span class="title">素材类型：</span>
                    <select field="type_id">
                        <option value="-1">一 不限 一</option>
                        <option value="0">图文消息</option>
                        <option value="1">文本内容</option>
                        <option value="2">链接</option>
                    </select>
                </li>
                <li>
                    <span class="title">排序：</span>
                    <select field="sort">
                        <option value="CreateTime">添加时间-顺序</option>
                        <option value="CreateTime DESC">添加时间-倒序</option>
                        <option value="UpdateTime">修改时间-顺序</option>
                        <option value="UpdateTime DESC">修改时间-倒序</option>
                    </select>
                </li>

                <li>
                    <span class="title">素材键：</span>
                    <input type="text" field="res_key" style="width:100px" />
                </li>
               
                <li>
                    <a class="easyui-linkbutton" id="btnSearch">搜索</a>
                    <a class="easyui-linkbutton" id="btnClear">清空条件</a>
                </li>
            </ul>

            <div class="clearfix"></div>

            <div style="text-align: right;position:absolute;right:50px;top:10px">
                <a class="easyui-linkbutton" onclick="add(1)">添加文本素材</a>
                <a class="easyui-linkbutton" onclick="add(2)">添加图文素材</a>
            </div>

        </div>
    </div>


    <script type="text/javascript" src="${os.mjs}"></script>
    <script src="${os.ppath}/js/EasyUi/jquery.min.js" type="text/javascript"></script>
    <script src="${os.ppath}/js/EasyUi/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="${os.ppath}/js/EasyUi/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="${os.ppath}/js/export.js" type="text/javascript"></script>
    <script src="${os.ppath}/js/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        expr.ele = 'searchbar';
        expr.portal = 'ResourceList';   //配置导出的入口
        expr.checkParams = function (data) {
            return true;
        };

        var Search = function () { expr.search('gd'); };
        var refresh = function () { expr.reload('gd'); };

        $JS.$('gd').style.height = $JS.screen.height() + 'px';

        $(function () {

            //导出
            $('#btnExport').click(
                function () {
                    //alert('提示：\n建议导出选择【csv格式】,兼容性更好，可以用各种版本excel打开！');
                    expr.showExportDialog();
                });

            $('#btnClear').click(
                function () {
                    J.json.bind('searchbar', { state: -1, province: '', cashNo: '', caseNo: '', partnerCode: '', contract: '', startTime: '', endTime: '' });
                });

            $('#btnSearch').click(
                function () {
                    $('#gd').datagrid('clearSelections');
                     expr.search('gd');
                });


            //下载文件
            var dl = function (type) {
                var rows = $('#gd').datagrid('getSelections');
                if (rows.length == 0) {
                    $.messager.alert('提示', '请选择要下载的图片');
                } else {
                    //var data = $JS.json.toQueryString(expr.ele);
                    var data = 'caseIds=';
                    for (var i = 0; i < rows.length; i++) {
                        if (i != 0) data += ',';
                        data += rows[i].id;
                    }
                    location.href = '/cir.sh.aspx/dl_gallery2?imgType=' + type + '&' + data;
                }
            };


            //编辑
            window.showDetail = function (id) {
                openPage('查看订单详情', 'MerchantQuery/ShowOrderDetail?source=OfflineShop&orderNo=' + id);
                //PW.getWindow("ShowOrderDetail?source=OfflineShop&orderNo=" + id, "查看订单详情", 600, 400);
            };


            //格式化操作
            window.opFormat = function (value, row) {
                return "<a href=\"javascript:void(0)\" onclick=\"showDetail('" + row.ID + "')\">详情</a>";
            };

            //加载数据
            $('#gd').datagrid({
                toolbar: '.toolBar',
                pageList: [15, 20, 30, 50],
                pageSize: 15,
                singleSelect: true,
                pagination: true,
                rownumbers: true,
                idField: 'id',
                fitColumns: true,
                url: expr.getDataUrl(),
                columns: [[
                    { field: 'id1', title: '选择', checkbox: true },
                    { field: 'ResKey', title: '素材Key', align: 'center', width: 150 },
                    { field: 'TypeName', title: '素材类型', align: 'center', width: 150 },
                    {
                        field: 'CreateTime', title: '创建时间', align: 'center', width: 150, formatter: function (v, r) {
                            return v.replace(/T|(\.)(\d+)$/g, ' ');
                        }
                    },
                    { field: 'UpdateTime', title: '最后修改时间', align: 'center',width: 150,formatter:function(v,r){
                           return v.replace(/T|(\.)(\d+)$/g, ' ');
                       }},
                    {
                        field: 'op',
                        title: '操作',
                        align: 'center',
                        width: 200,
                        formatter: function(v, r) {
                            return (r.TypeId == 2?'<a href="javascript:void(0);" onclick="item(' + r.Id + ',' + r.TypeId + ')">子项</a> | ':'')+
                                '<a href="javascript:;" onclick="edit(' + r.Id + ',' + r.TypeId + ')">修改</a> |' +
                                ' <a href="javascript:;" onclick="del(' + r.Id + ')">删除</a>';
                        }
                    }
                ]]
            });

            //统计汇总数量
            // expr.bindTotalView('totalView');
        });

        function add(type) {
            if (type == 1) {
                var dia = $JS.dialog.create2('添加文本素材', true, true);
                dia.open('/wxm/createTextRes', 800, 500);
            } else {
                var dia = $JS.dialog.create2('添加图文素材', true, true);
                dia.open('/wxm/createArticleRes', 400, 200);
            }
        }

        function edit(id,type)
        {
            if (type == 1) {
                var dia = $JS.dialog.create2('修改文本素材',true,true);
                dia.open('/wxm/editTextRes?id='+id, 800, 500);
            } else {
                var dia = $JS.dialog.create2('修改图文素材', true, true);
                dia.open('/wxm/editArticleRes?id='+id, 400, 200);
            }
        }

        function item(id) {
           $JS.tab.open('图文子项管理', '/wxm/ArticleItems?res_id=' + id, true);
        }

        function del(id) {
            if (confirm('确定要素材吗？')) {
                J.xhr.jsonPost('delres', { id: id }, function (json) {
                    if (json.result) {
                        $.messager.alert('提示', json.message, 'ok', function() {
                            expr.reload('gd');
                        });
                    } else {
                        $.messager.alert('提示', json.message);
                    }
                });
            }
        }

    </script>
</body>
</html>